package com.example.helloandroid;

import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class TestFasterDynamicList extends ListActivity {

	TextView selection;
	private String itemList[] = {"my","first", "faster", "list" };
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setListAdapter(new IconAdapter(this));
		//setListAdapter(new ArrayAdapter<String>(this, R.layout.faster_row_list, R.id.RowTextView, itemList));
		selection =  (TextView) findViewById(R.id.RowTextView);
		
	}
	
	class IconAdapter extends ArrayAdapter {
		Activity context;
		
		public IconAdapter(Activity context) {
			super(context, R.layout.faster_row_list, itemList);
			this.context = context;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			View row = convertView;
			if (row == null)
			{
				LayoutInflater inflater = context.getLayoutInflater();
				row = inflater.inflate(R.layout.faster_row_list, null);				
			}

			TextView label = (TextView) row.findViewById(R.id.RowTextView);
			if (position > 1)
			{
				label.setText("Pippo");
				((ImageView) row.findViewById(R.id.ImageView01)).setImageResource(R.drawable.check);
			}
			else 
				label.setText(itemList[position]);
			return row;
		}
		
		
	}

}
